package com.msc.sdm.web.faces.beans;

import com.msc.sdm.application.ExecutionContext;
import com.msc.sdm.application.SdmUserSession;
import com.msc.sdm.exception.SdmException;
 
import javax.faces.FacesException;

public class User {
	public String getName() {
		return getUserSession().getUserName();
	}

	public String getProfile() {
		try {
			return getUserSession().getProfileName();
		} catch (SdmException localSdmException) {
			throw new FacesException(localSdmException);
		}
	}

	public String getUserSessionObjectId() {
		return getUserSession().getSessionId().getHandle();
	}

	public String getRealName() {
		String userRealName = "";
		try {
			userRealName = ExecutionContext.getInstance().getClientConnection()
					.lookupObject("User", "[name=='" + getName() + "']").evaluate("userRealName").getString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return userRealName;
	}

	protected SdmUserSession getUserSession() {
		try {
			return ExecutionContext.getInstance().getUserSession();
		} catch (SdmException localSdmException) {
			throw new FacesException(localSdmException);
		}
	}
}
